

package com.shop.cloud.upms.admin.properties;

import cn.hutool.core.util.StrUtil;
import com.shop.cloud.common.core.constant.CommonConstants;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

/**
 * 前端h5默认域名配置
 * @author
 */
@Data
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = "base.h5portal.path")
public class H5portalPathProperties {

	/**
	 * pc端默认域名
	 */
	private String pc;
	/**
     * 移动端默认域名
	 */
	private String mobile;

	/**
	 * 通过类型获取对应的域名
	 * @param type
	 * @return
	 */
	public String getPath(String type){
		if(StrUtil.isBlank(type) || (!CommonConstants.H5PORTALDOMAIN_TYPE_1.equals(type)
				&& !CommonConstants.H5PORTALDOMAIN_TYPE_2.equals(type))){
			throw new RuntimeException("非法域名类型");
		}
		return CommonConstants.H5PORTALDOMAIN_TYPE_1.equals(type) ? this.getPc() : this.getMobile();
	}
}